﻿@page "/mainplan/update/drwreleasetime/{Id}"
@inject IMainPlanService MainPlanService

@inject NavigationManager NavigationManager
<PageTitle>更新发图时间</PageTitle>
<EditForm Model="_mainPlanDto" OnSubmit="Save">
    <div class="input-group mb-2" style="max-width: 250px">
        <span class="input-group-text">发图时间</span>
        <input type="date" class="form-control" @bind-value="@_mainPlanDto.DrwReleaseTime" />
    </div>
    
    <CompSaveCancelButtons CancelUrl="" />
</EditForm>
@code {
    [Parameter]
    public string Id { get; set; }
    private MainPlanDto? _mainPlanDto = new();
    protected override async Task OnInitializedAsync()
    {
        var response = await MainPlanService.GetFirstOrDefaultAsync(Guid.Parse(Id));
        if (!response.Status) NavigationManager.NavigateTo("");
        _mainPlanDto = response.Result;
        _mainPlanDto.DrwReleaseTime=DateTime.Today;
    }
    private async Task Save()
    {
        var result = await MainPlanService.UpdateStatusesAsync(Guid.Parse(Id), _mainPlanDto);
        if (result.IsSuccessStatusCode) NavigationManager.NavigateTo("");
    }
}
